import axios from '@/utils/axios'

export const getFencesByElderly = (elderlyUserId) =>
    axios.get(`http://localhost:8080/api/v1/family_user/fence/elderly/${elderlyUserId}`)

export const addFence = (data) =>
    axios.post('http://localhost:8080/api/v1/family_user/fence/add', data)

export const updateFence = (data) =>
    axios.put(`http://localhost:8080/api/v1/family_user/fence/update/${data.fenceId}`, data)

export const deleteFence = (id) =>
    axios.delete(`http://localhost:8080/api/v1/family_user/fence/delete/${id}`)

// 百度 POI 搜索（浏览器端直接调用，无需后端转发）
export const searchPoi = ({ keyword, city = '全国' }) =>
    axios.get('https://api.map.baidu.com/place/v2/search', {
        params: {
            ak: 'ZFFYeb35z0tlgY64OfbtMfg9SV7KNxzW',
            output: 'json',
            query: keyword,
            region: city,
            city_limit: true
        }
    })